package com.hsj.completionservice;

import java.util.concurrent.Callable;

public class Task implements Callable<Integer> {
    Integer i;

    public Task(Integer i) {
        super();
        this.i=i;
    }

    @Override
    public Integer call() throws Exception {
        if(i==5){
            Thread.sleep(5000);
        }else{
            Thread.sleep(1000);
        }
        System.out.println("线程："+Thread.currentThread().getName()+"任务i="+i+",执行完成！");
        return i;
    }

}